package com.csoa.community.requests;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.chinaface.JSONArray;
import org.json.chinaface.JSONObject;

import android.util.Log;

import com.csoa.community.bean.TongZhiModel;
import com.csoa.community.net.ErrorMsg;
import com.csoa.community.utils.StringUtils;

public class TongZhiRequest extends AbstractRequest {

	public List<TongZhiModel> data;
	public TongZhiRequest(List<BasicNameValuePair> requestValues) {
		super(method_tongzhi_list, requestValues);
	}

	@Override
	protected void parseRemaingInfo(String json) throws ErrorMsg, JSONException {
		
		if(!StringUtils.isEmpty(json)) {
			
			if (data == null) {
				data = new ArrayList<TongZhiModel>();
			}
			
			data.clear();
			
			try {
				JSONArray ja = new JSONArray(json);
				TongZhiModel model;
				JSONObject jb;
				for (int i = 0; i < ja.length(); i++) {
					model = new TongZhiModel();
					jb = ja.getJSONObject(i);
					Log.e("", jb.toString());
					model.id = jb.getString("DocumentID");
					model.name = jb.getString("Title");
					model.time = jb.getString("PassDateTime");
					data.add(model);
				}
			} catch (org.json.chinaface.JSONException e) {
				e.printStackTrace();
			}
		}
		
	}
}
